use t::MYTEST 'no_plan';

# PERL5LIB=.:$PERL5LIB prove t/core/log.t -v

# repeat_each。它其实是一个 perl 函数，默认情况下是 repeat_each(1)，表示测试案例只运行一次
repeat_each(1);
no_long_string();
no_root_location();

run_tests();


__DATA__
=== TEST 1: filter.json rule1
`"value": "\.(bak|inc|old|mdb|sql|backup|java|class)$"`

--- config
    location /t {
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /t/1.bak","GET /t/1.inc","GET /t/1.old","GET /t/1.mdb","GET /t/1.sql","GET /t/1.backup","GET /t/1.java","GET /t/1.class","GET /t"]
--- error_code eval
[403,403,403,403,403,403,403,403,200]


=== TEST 2: filter.json rule2
`"value": "(vhost|bbs|host|wwwroot|www|site|root|hytop|flashfxp).*\.rar"`

--- config
    location /t {
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /t/vhost1.rar","GET /t/bbs.rar","GET /t/host2.rar","GET /t/wwwroot.rar","GET /t/www.rar","GET /t/site.rar","GET /t/root.rar","GET /t/hytop.rar","GET /t/flashfxp.rar","GET /t"]
--- error_code eval
[403,403,403,403,403,403,403,403,403,200]


=== TEST 3: filter.json rule3
`"value": "(phpmyadmin|jmx-console|jmxinvokerservlet)"`

--- config
    location /t {
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /t/phpmyadmin.php","GET /t/jmx-console","GET /t/jmxinvokerservlet","GET /t/jmxinvo1kerservlet"]
--- error_code eval
[403,403,403,200]
